import request from './request.js';

const key = '14a31b031930e6527b669b37ad21b8f6';

//根据ip获取自身所在城市信息
export const getCityByIP = () => {
    return request({
        method: 'get',
        url: `/ip?key=${key}`,
    })
}

//根据城市名称获取城市的adcode
export const getAdcodeByCity = (name) => {
    return request({
        method: 'get',
        url: `/geocode/geo?address=${name}&key=${key}`,
    })
}

//根据城市的adcode来获取城市的阿里云GeoJSON数据
export const getGeoJSONByAdcode = (adcode) => {
    return request({
        method: 'get',
        url: `https://geo.datav.aliyun.com/areas_v3/bound/${adcode}.json`,
        baseURL: '', // 覆盖默认的baseURL
    })
}
